<?php $this->pageTitle=Yii::app()->name; ?>
<div class="body-cont">
<div class="form">
<script type="text/javascript">
$(document).ready(function(){
   $("#jobtype_id").change(function(){
        $("#chonlinhvuc").show();

   });
   $(this).submit(function(){
           for ( var i = 0 ; i < $('.cb_skill:checkbox').length; i++ ){
               $('.cb_skill:checkbox').get(i).disabled = false;
           }
   });

});
</script>   
<h1>Đăng ký dự án mới </h1>
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'job-form',
	'enableClientValidation'=>true,
	'enableAjaxValidation'=>true,
	'htmlOptions' => array('enctype' => 'multipart/form-data',)
)); ?>
<?php if(Yii::app()->user->hasFlash('error1')):?>
    	<div class="info" style="color: red;">
        	<?php echo Yii::app()->user->getFlash('error1'); ?>
    	</div>
	<?php endif; ?>

<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>200)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row">

		<?php echo $form->labelEx($model,'jobtype_id'); ?>
		<?php echo CHtml::dropDownList('jobtype_id','',$model->getJobType(),array('prompt' => 'Chọn một lĩnh vực',
                    'ajax' => array(
                    'type'=>'POST', //request type
                    'url'=>CController::createUrl('/job/create/ajaxdropdown'),
                    //Style: CController::createUrl('currentController/methodToCall')
                    'update'=>'#subjobtype_id', //selector to update
                    //'data'=>'js:javascript statement'
                    //leave out the data key to pass all form values through

                    )));

?>
		<?php echo $form->error($model,'jobtype_id'); ?>

	</div>
    <div class="row" id="chonlinhvuc" style="display: none;" >
		<?php echo $form->labelEx($model,'subjobtype_id'); ?>
		<?php echo CHtml::dropDownList('subjobtype_id','', array(),array('prompt' => 'Chọn một lĩnh vực',
                    'ajax' => array(
                    'type'=>'POST', //request type
                    'url'=>CController::createUrl('/job/create/ajaxskill'),//update du lieu trong jquery va xu ly bang jquey
                     'success'=> "function(data) {
                        $('#job_skill').html(data);
                        $('.cb_skill:checkbox').click(function(){
                            if ( $('.cb_skill:checkbox:checked').length >=".Yii::app()->getModule('job')->amountSkill." ){
                                for ( var i = 0 ; i < $('.cb_skill:checkbox').length; i++ ){
                                    $('.cb_skill:checkbox').get(i).disabled = true;
                                }
                                $('#del_enable').show();

                                }
                        });
                        $('#del_enable').click(function(){
                            jQuery('.cb_skill').removeAttr('checked');
                            for ( var i = 0 ; i < $('.cb_skill:checkbox').length; i++ ){
                                    $('.cb_skill:checkbox').get(i).disabled = false;
                                }
                                $('#del_enable').hide();
                                }
                                );

                        return data;
                    }",
                    //'data'=>'js:javascript statement'
                    //leave out the data key to pass all form values through
                    )));   ?>
		<?php echo $form->error($model,'subjobtype_id'); ?>

        </div>

	<div class="row" id="job_skill">
        <a id='del_enable' style="display: none;"><h4>Bạn thay đổi lại khả năng của dự án</h4></a>
        </div>
	<div class="row">

		<?php echo $form->labelEx($model,'timeend'); ?>
		<?php echo CHtml::dropDownList('timeend','', $model->getTimeEnd(),array('prompt' => 'Chọn khoảng thời gian',)); ?>
		<?php echo $form->error($model,'timeend'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'budget_id'); ?>
        <?php echo CHtml::dropDownList('currency','',$model->getJobCurrency(),array(
                    'ajax' => array(
                    'type'=>'POST', //request type
                    'url'=>CController::createUrl('/job/create/ajaxcurrency'), //url to call.
                    //Style: CController::createUrl('currentController/methodToCall')
                    'update'=>'#'.CHtml::activeId($model,'budget_id'), //selector to update
                    //'data'=>'js:javascript statement'
                    //leave out the data key to pass all form values through
                    )));

?>
		<?php echo $form->dropDownlist($model,'budget_id', array('prompt' => 'Chọn khoảng tiền')); ?>
		<?php echo $form->error($model,'budget_id'); ?>
	</div>
    <div class="row">
          <?php echo $form->labelEx($model,'statuspost'); ?>
          <?php echo $form->checkBox($model,'statuspost'); ?>
        <?php echo $form->error($model,'statuspost'); ?>

    </div>
	<div class="row">
		<?php echo $form->labelEx($model,'jobdesc'); ?>
		<?php echo $form->textArea($model,'jobdesc',array('rows'=>10, 'cols'=>80)); ?>
		<?php echo $form->error($model,'jobdesc'); ?>
	</div>
	<div class="row">
            <?php
                echo $form->labelEx($model,'fileattached');
                echo Chtml::activeFileField($model, 'fileattached');
                echo Chtml::error($model, 'fileattached');
            ?>
	</div>
        Chú ý: Bạn không được đăng thông tin cá nhân nào trên website này!!

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
</div>